//
//  UIView+Helper.m
//  Qicai
//
//  Created by eims on 15/6/6.
//  Copyright (c) 2015年 7ien. All rights reserved.
//

#import "UIView+Helper.h"

@implementation UIView (Helper)

- (CGFloat)getMinY {
    return CGRectGetMinY(self.frame);
}

- (CGFloat)getMidY {
    return CGRectGetMidY(self.frame);
}

- (CGFloat)getMaxY {
    return CGRectGetMaxY(self.frame);
}

- (CGFloat)getMinX {
    return CGRectGetMinX(self.frame);
}

- (CGFloat)getMidX {
    return CGRectGetMidX(self.frame);
}

- (CGFloat)getMaxX {
    return CGRectGetMaxX(self.frame);
}

- (CGFloat)getWidth {
    return CGRectGetWidth(self.frame);
}

- (CGFloat)getHeight {
    return CGRectGetHeight(self.frame);
}

- (void)setGolf_left:(CGFloat)golf_left
{
    CGRect frame = self.frame;
    frame.origin.x = golf_left;
    self.frame = frame;
}

- (CGFloat)golf_left
{
    return self.frame.origin.x;
}

- (void)setGolf_top:(CGFloat)golf_top
{
    CGRect frame = self.frame;
    frame.origin.y = golf_top;
    self.frame = frame;
}

- (CGFloat)golf_top
{
    return self.frame.origin.y;
}

- (void)setGolf_right:(CGFloat)golf_right
{
    CGRect frame = self.frame;
    frame.origin.x = golf_right - frame.size.width;
    self.frame = frame;
}

- (CGFloat)golf_right
{
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setGolf_bottom:(CGFloat)golf_bottom
{
    CGRect frame = self.frame;
    frame.origin.y = golf_bottom - frame.size.height;
    self.frame = frame;
}

- (CGFloat)golf_bottom
{
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setGolf_width:(CGFloat)golf_width
{
    CGRect frame = self.frame;
    frame.size.width = golf_width;
    self.frame = frame;
}

- (CGFloat)golf_width
{
    return self.frame.size.width;
}

- (void)setGolf_height:(CGFloat)golf_height
{
    CGRect frame = self.frame;
    frame.size.height = golf_height;
    self.frame = frame;
}

- (CGFloat)golf_height
{
    return self.frame.size.height;
}

- (void)setGolf_centerX:(CGFloat)golf_centerX
{
    self.center = CGPointMake(golf_centerX, self.center.y);
}

- (CGFloat)golf_centerX
{
    return self.center.x;
}

- (void)setGolf_centerY:(CGFloat)golf_centerY
{
    self.center = CGPointMake(self.center.x, golf_centerY);
}

- (CGFloat)golf_centerY
{
    return self.center.y;
}

- (void)setGolf_origin:(CGPoint)golf_origin
{
    CGRect frame = self.frame;
    frame.origin = golf_origin;
    self.frame = frame;
}

- (CGPoint)golf_origin
{
    return self.frame.origin;
}

- (void)setGolf_size:(CGSize)golf_size
{
    CGRect frame = self.frame;
    frame.size = golf_size;
    self.frame = frame;
}

- (CGSize)golf_size
{
    return self.frame.size;
}

- (UIImage *)imageWithColor:(UIColor *)color
{
    CGSize imageSize = self.frame.size;
    UIGraphicsBeginImageContextWithOptions(imageSize, 0, [UIScreen mainScreen].scale);
    [color set];
    UIRectFill(CGRectMake(0, 0, imageSize.width, imageSize.height));
    UIImage *pureColorImage = (UIImage *)UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return pureColorImage;
}

- (UIImage *)golf_snapshotImage {
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *snap = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return snap;
}



@end
